package com.example.demo.util;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @Author: huanggaotao
 * @Description:
 * @Date: Created in 15:35 2021/4/21
 * @Modified By:
 */
public class Jwtjiexi {
    private static final String signKey = "mayiktSign";

    public static void main(String[] args) {

//        String jwt = "eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1OTE0MjY4MjEsInVzZXJJZCI6IjY0NDA2NCJ9.86LauCphjTZrQdmcRVuM7Nr4IpJDwdkKI5k2cjg91rQ";
//
//        Claims body = Jwts.parser().setSigningKey(signKey).parseClaimsJws(jwt).getBody();
//
//
//        System.out.println(body.get("iat"));

        String jwt = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxIiwic3ViIjoiaHVuZ2dhb3RhbyIsImlhdCI6MTYxODk4NjMwNn0.vZAYmxleOMhfhpgbY3pN_ChFQxj2CNnL5PMm0xaIjSU";

        String jwt1 = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.78YmOnUold7aEnlV5KIopGUtZ6W8b6DoRnOoXtyeLxk";

       // Claims hgtSignKey = Jwts.parser().setSigningKey("hgtSignKey").parseClaimsJws(jwt).getBody();

        Claims body = Jwts.parser().setSigningKey("hgt").parseClaimsJws(jwt1).getBody();

       // System.out.println(hgtSignKey.get("sub"));
        System.out.println(body.get("sub"));

    }
}
